#pragma once

#include "Reflection/Type.h"
#include "Reflection/TypeInstance.h"

class CGSharpFieldValuesContainer;

class WHENGINE_API CGSharpStruct : public CType
{
public:
    CGSharpStruct(
        const STypeID &InTypeID
        ,ETypeFlags InExtraFlags
    );

    ~CGSharpStruct();

    CGSharpFieldValuesContainer* GetStaticValues() const;

protected:
    class CScriptStructInstance : public ITypeInstance
    {
    protected:
        CGSharpStruct * StructType;
    public:
        CScriptStructInstance(CGSharpStruct * InStructType)
            :StructType(InStructType)
        {
        }

        virtual uint32_t GetSize() override;
        virtual uint64_t GetInstanceHash(const void * Instance) const override;
        
        virtual bool IsInstanceEqual(const void * Instance0,const void * Instance1) const override;
        virtual void InitInstance(void* Memory) override; 
        virtual void EraseInstance(void* Instance) override; 
        virtual void CloneInstance(const void* Instance,void * TargetMemory); //clone instance of this type

        virtual void ResetAllocated(void* Memory) override ;
    
    
        virtual CString ToDebugString(const void * Instance) const override;
    	virtual int64_t GetDebugNamedChildNum(const void * Instance) const override;
        virtual CType* GetDebugNamedChildType(int64_t Index,const void * Instance) const override;
        virtual CString GetDebugNamedChildName(int64_t Index,const void * Instance) const override;
        virtual const void* GetDebugNamedChildValue(int64_t Index,const void * Instance) const override;
    };

    CGSharpFieldValuesContainer* StaticFieldValues= nullptr;

    static void OnPostConstruct(CGSharpStruct * InStruct);

};